@echo off
chcp 65001
echo 1、执行打包脚本至DEV环境
call mvn package -Dmaven.test.skip=true -Dmaven.compile.fork=true -Pdev

set CurrentDir=%cd%
set TargetFolder=target\

echo %CurrentDir%%TargetFolder%
set JAVA_BASE_OPTS=-server -Xms256m -Xmx256m -XX:+UseCompressedOops -XX:GCLogFileSize=512K -XX:-PrintGCDetails -XX:-HeapDumpOnOutOfMemoryError

if not exist %CurrentDir%%TargetFolder% (
	md %cd%\target
)

echo 2、复制打包后的文件至target文件夹

copy %currentDir%\drainage-core-parent\drainage-eureka\target\drainage-eureka-1.0.0-SNAPSHOT.jar %TargetFolder%
copy %currentDir%\drainage-parent\drainage-base-parent\drainage-msg-103\target\drainage-msg-103-1.0.0-SNAPSHOT.jar %TargetFolder%
copy %currentDir%\drainage-parent\drainage-base-parent\drainage-log-102\target\drainage-log-102-1.0.0-SNAPSHOT.jar %TargetFolder%
copy %currentDir%\drainage-parent\drainage-base-parent\drainage-auth-101\target\drainage-auth-101-1.0.0-SNAPSHOT.jar %TargetFolder%
copy %currentDir%\drainage-core-parent\drainage-gateway\target\drainage-gateway-1.0.0-SNAPSHOT.jar %TargetFolder%


cd %TargetFolder%

set JAVA_OPTS=%JAVA_BASE_OPTS% -XX:ErrorFile=hs_err_eureka.log -XX:HeapDumpPath=java_eureka.hprof -Xloggc:gc_eureka.log
start java %JAVA_OPTS% -jar drainage-eureka-1.0.0-SNAPSHOT.jar
timeout /T 3 /NOBREAK

set JAVA_OPTS=%JAVA_BASE_OPTS% -XX:ErrorFile=hs_err_msg.log -XX:HeapDumpPath=java_msg.hprof -Xloggc:gc_msg.log
start java %JAVA_OPTS% -jar drainage-msg-103-1.0.0-SNAPSHOT.jar
timeout /T 3 /NOBREAK

set JAVA_OPTS=%JAVA_BASE_OPTS% -XX:ErrorFile=hs_err_log.log -XX:HeapDumpPath=java_log.hprof -Xloggc:gc_log.log
start java %JAVA_OPTS% -jar drainage-log-102-1.0.0-SNAPSHOT.jar
timeout /T 3 /NOBREAK

set JAVA_OPTS=%JAVA_BASE_OPTS% -XX:ErrorFile=hs_err_auth.log -XX:HeapDumpPath=java_auth.hprof -Xloggc:gc_auth.log
start java %JAVA_OPTS% -jar drainage-auth-101-1.0.0-SNAPSHOT.jar
timeout /T 3 /NOBREAK

set JAVA_OPTS=%JAVA_BASE_OPTS% -XX:ErrorFile=hs_err_gateway.log -XX:HeapDumpPath=java_gateway.hprof -Xloggc:gc_gateway.log
start java %JAVA_OPTS% -jar drainage-gateway-1.0.0-SNAPSHOT.jar

pause